$.ajax({
	type: "post",
	dataType: "json",
	url: "http://www.516code.cn/homePage/homepage/QueryLeavworAll.do",
	success: function(msg) {
		for(var i = 0; i < msg.data.length; i++) {
			$(".liuyanban").append("<img src='http://www.516code.cn/箭头.png'><span>" + msg.data[i].leaveName + "：</span><label>" + msg.data[i].leaveMsg + "</label></p>");
		}
	}
})
$("input[name=liuyan]").click(function() {
	var time=1;
	var code=$(".errer")
	setInterval(function() {      
		time--;      
		if(time == 0) {      
			code.text(""); 
		}     
	}, 1000);
	$(".errer").text("");
	var name = $("input[name=name]").val();
	var Phone = $("input[name=Phone]").val();
	var msg = $("#guestbook").val();
	if(name == "" || Phone == "" || msg == "") {
		$(".errer").text("姓名，电话，留言信息不能为空");
		return;
	} else {
		$.ajax({
			type: "post",
			dataType: "json",
			data: {
				leaveName: name,
				leavePhone: Phone,
				leaveMsg: msg,
			},
			url: "http://www.516code.cn/homePage/homepage/InsertLeaveword.do",
			success: function(msg) {
				var yan = msg.data;
				$(".errer").text(yan);
				$(".liuyanban").empty();
				$.ajax({
					type: "post",
					dataType: "json",
					url: "http://www.516code.cn/homePage/homepage/QueryLeavworAll.do",
					success: function(msg) {
						for(var i = 0; i < msg.data.length; i++) {
							$(".liuyanban").append("<img src='http://www.516code.cn/箭头.png'><span>" + msg.data[i].leaveName + "：</span><label>" + msg.data[i].leaveMsg + "</label></p>");
						}
					}
				})
			}
		})
	}
})